<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script src="../3-jq效果/js/jquery.min.js"></script>
</head>

<body>
    <div>1</div>
    <div>2</div>
    <div>3</div>

    <script>
        $(function () {

            let arr = ['red', 'green', 'blue'];

            $('div').each(function (i, domEle) {
                // 回调函数第一个参数，一定是索引号，可以自己制定索引号，号名称
                // console.log(index);
                console.log(i);
                // 回调函数第二个参数一定是dom元素对象
                console.log(domEle);
                // domEle.css('color'); dom对象没有css方法;
                $(domEle).css('color', arr[i]);
            })

            $.each(arr, function (i, ele) {
                console.log(i);
                console.log(ele);
            });

            let object = {
                name: 'andy',
                age: 18
            }
            $.each(object, function (i, ele) {
                console.log(i); // 属性名，键名
                console.log(ele); // 属性值，键值
            })
        })
    </script>
</body>

</html>